import api from './api.js'
import request from './request.js'

export async function getDictionaryByType(e){
    let a = []
    await request.get(api.getDictionaryByType, {
        dictionaryType:e,
    }).then(res =>{
        if(res.code == 200){
            a = res.data
        }
    })
    return a
}

export async function queryNameDuplicate(id,e,type){
    if(e.e != undefined && e.e != ''){
        let a = ''
        await request.postForm(api.queryNameDuplicate, {
            groupId:id,
            equipType:type,
            equipmentName:e.e
        })
        .then(res=>{
            if(res.code == 200){
                if(res.data == false){
                    this.$message.warning('此名称在分组下重复，请重新输入！')
                    a = false
                }
            }
        })
        return a
    }else{
        this.$message.warning('名称不能为空！')
    }
}

export async function duplicateQueryGroupName(name,type,id){
    if(name!= undefined && name != ''){
        await request.postForm(api.duplicateQueryGroupName, {
            groupName:id,
            groupType:type,
            companyId:name
        }).then(res=>{
            if(res.code != 200){
                this.$message.warning('分组已存在，请重新输入！')
            }
        })
    }else{
        this.$message.warning('分组不能为空！')
    }
}